import request from '@/utils/request'

export function getCustomNodeTemplate() {
  return request({
    url: 'draw/getTemplate',
    method: 'get'
  })
}

export function saveCustomNodeTemplate(fileContent) {
  return request({
    url: 'draw/saveTemplate',
    method: 'post',
    data: fileContent
  })
}

export function getDeviceTree() {
  return request({
    url: 'draw/getDeviceTree',
    method: 'get'
  })
}

export function getAnalogTree(deviceId) {
  return request({
    url: 'draw/getAnalogTree',
    method: 'get',
    params: {
      deviceId: deviceId
    }
  })
}

export function getElectricTree(substationId) {
  return request({
    url: 'draw/getElectricTree',
    method: 'get',
    params: {
      substationId: substationId
    }
  })
}

export function getSubstationTree() {
  return request({
    url: 'draw/getSubstationTree',
    method: 'get'
  })
}

export function getBusTree() {
  return request({
    url: 'draw/getBusTree',
    method: 'get'
  })
}

export function getLineTree() {
  return request({
    url: 'draw/getLineTree',
    method: 'get'
  })
}

export function getBreakerTree() {
  return request({
    url: 'draw/getBreakerTree',
    method: 'get'
  })
}

export function getChannelTree() {
  return request({
    url: 'draw/getChannelTree',
    method: 'get'
  })
}

export function getConditionTree() {
  return request({
    url: 'draw/getConditionTree',
    method: 'get'
  })
}

export function addGraphFile(graphFile) {
  return request({
    url: 'graphFile/add',
    method: 'post',
    data: graphFile
  })
}

export function updateGraphFile(graphFile) {
  return request({
    url: 'graphFile/update',
    method: 'post',
    data: graphFile
  })
}

export function deleteGraphFile(graphFile) {
  return request({
    url: 'graphFile/delete',
    method: 'post',
    data: graphFile
  })
}

export function getGraphFile(fileId) {
  return request({
    url: 'graphFile/getFile',
    method: 'get',
    params: {
      fileId: fileId
    }
  })
}

export function getGraphFileInfos() {
  return request({
    url: 'graphFile/getFileInfos',
    method: 'get'
  })
}

export function existGraphFile(fileName) {
  return request({
    url: 'graphFile/existFile',
    method: 'get',
    params: {
      fileName: fileName
    }
  })
}

export function addGraphNode(graphNode) {
  return request({
    url: 'graphFile/addNode',
    method: 'post',
    data: graphNode
  })
}

export function updateGraphNode(graphNode) {
  return request({
    url: 'graphFile/updateNode',
    method: 'post',
    data: graphNode
  })
}

export function deleteGraphNode(graphNode) {
  return request({
    url: 'graphFile/deleteNode',
    method: 'post',
    data: graphNode
  })
}

export function getGraphNodes() {
  return request({
    url: 'graphFile/getAllNode',
    method: 'get'
  })
}
